package com.by.service.impl;

import com.by.bean.Employee;
import com.by.common.bean.Page;
import com.by.common.bean.PageBean;
import com.by.mapper.EmployeeMapper;
import com.by.service.EmployeeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @author HY
 * @version 1.0
 * @description
 * @date 2025/2/18
 * @since JDK21
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    EmployeeMapper employeeMapper;

    @Override
    public List<Employee> queryByName(String name,String departmentName) {

        return  employeeMapper.query(name,departmentName);
    }

    @Override
    public int save(Employee employee) {

        return employeeMapper.save(employee);
    }

    @Override
    public int update(Employee employee) {
        return employeeMapper.update(employee);
    }

    @Override
    public int delete(String id) {
        return employeeMapper.delete(id);
    }

    @Override
    public PageBean queryList(int page, int pageSize) {
        PageHelper.startPage(page,pageSize);
        List list = employeeMapper.queryList();
        PageInfo info = new PageInfo(list);
        return new  PageBean(page,pageSize,(int)info.getTotal(),list);

    }
}
